<?php
    use User\Model\ApplicationsModel;
?>
<style>
    .table>thead>tr>th{text-align: center;}
    .table>tbody>tr>td{vertical-align: middle; text-align: center; border-top:0}
    .btn-custom{color:white} .btn-custom:hover{color:white}
    .color2{background-color:#5CB85C} .color3{background-color:#D9534F} .color4{background-color:#66CCFF}
    .avatar{width:50px;height:50px}
</style>
<div id="page-wrapper">
    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header">
                <span>举报内容</span>
            </h3>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <button class="btn btn-success" onclick="return download();">导出</button>
                </div>
                <div class="panel-body">
                    <div class="form-horizontal">
                        <div class="tab-content">
                            <div class="tab-pane active">
                                <div class="panel-body">
                                    <table class="table table-bordered">
                                        <thead>
                                        <tr>
                                            <th width="200px;">举报内容</th>
                                            <th width="200px;">单位</th>
                                            <th width="100px;">姓名</th>
                                            <th width="100px;">电话</th>
                                            <th>图片</th>
                                            <th width="150px;">举报时间</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <volist name="list" id="item">
                                            <tr>
                                                <td>{$item.content}</td>
                                                <td>{$item.company}</td>
                                                <td>{$item.name}</td>
                                                <td>{$item.telephone}</td>
                                                <td>
                                                    <if condition="$item.pic neq null">
                                                        <img src="{$item.pic}" alt="" style="width: 200px;height: 200px;">
                                                        <a class="btn btn-success" href="<?php
                                                        $pic_url = explode('/', $item['pic']);
                                                        $pic = '';
                                                        $count = sizeof($pic_url);
                                                        foreach($pic_url as $key=>$val){
                                                            if($key == ($count-1)){
                                                                $val = substr($val, 5);
                                                            }
                                                            $pic .= '/' . $val;
                                                        }
                                                        echo C('SITE_URL') . $pic;?>">查看原图</a>
                                                    </if>
                                                </td>
                                                <td>{$item.created_time}</td>
                                                <td><button class="btn btn-danger" onclick="delete_tip({$item.tip_id})">删除</button></td>
                                            </tr>
                                        </volist>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="pages">
                                    {$page}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function download(){
        window.location = '/User/Applications/exportTip';
        return false;
    }
    function delete_tip(id){
        $.ajax({
            type:'get',
            data:{
                id: id
            },
            url:'/User/Applications/delete_tip',
            success:function(res){
                window.location.reload();
            }
        })
    }
</script>